home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / LOGTEN.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  730b  |  37 lines

  1. /*********
  2. *
  3. * LOGTEN.C
  4. *
  5. * by Ralph Davis
  6. *
  7. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  8. *
  9. *  Syntax:  LOGTEN( <expN> )
  10. *  Return:  Log of <expN> to the base 10 if <expN> >= 0
  11.             INFINITY() if <expN> < 0.
  12. *********/
  13.  
  14. #include "trlib.h"
  15.  
  16. TRTYPE logten()
  17. {
  18.    double n, ret;
  19.  
  20.    if ( PCOUNT == 1 && ISNUM(1) )
  21.    {
  22.       n = _parnd(1);
  23.  
  24.       if (n < 0)                 /* Number cannot be negative */
  25.          _retnd(_tr_infinity());
  26.       else
  27.       {
  28.          /* Log of n to the base 10 = Log(n) divided by Log(10) */
  29.  
  30.          ret = _tr_log(n) / _tr_log(10.0);
  31.          _retnd( ret );
  32.       }
  33.    }
  34.    else
  35.       _retnd(ERROR);     /* ZERO value if error */
  36. }
  37.